from datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field
from pydantic.types import UUID4
from app.schemas.archivable import Archivable

# 基础模型
class PersonalizedWordLibraryBase(BaseModel):
    category_name: Optional[str] = Field(description="个性化词库分类名")
    # usage_count: Optional[int] = Field(description="使用次数")

# 创建模型
class PersonalizedWordLibraryCreate(PersonalizedWordLibraryBase):
    # category_name: Optional[str] = Field(description="个性化词库分类名")
    # usage_count: int = 0
    pass
# 更新模型
class PersonalizedWordLibraryUpdate(PersonalizedWordLibraryBase):
    pass

# 数据库基础模型
class PersonalizedWordLibraryInDBBase(PersonalizedWordLibraryBase, Archivable):
    id: UUID4
    usage_count: Optional[int]
    created_at: Optional[datetime]
    updated_at: Optional[datetime]

    # class Config:
    #     from_attributes = True
    #     protected_namespaces = ()
        # allow_population_by_field_name = True

# 返回模型
class PersonalizedWordLibrary(PersonalizedWordLibraryInDBBase):
    pass

# 数据库模型
class PersonalizedWordLibraryInDB(PersonalizedWordLibraryInDBBase):
    user_id: Optional[UUID4]
